<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page session="false" %>
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <script type="text/javascript" src="<c:url value="/resources/jquery/jquery-1.5.1.js" />
        "></script>

        <script type="text/javascript" src="<c:url value="/resources/jquery/jquery.form.js" />
        "></script>

        <script language="javascript" type="text/javascript">
            $(function(){
                var bind_demo = function(_element, _href){
                    /*
                     * 拦截所有可能的跳转功能
                     */
                    $(_element).load(_href, function(responseText, textStatus, XMLHttpRequest){
                        $("a").click(function(e){ //绑定加载页面中所有的链接点击后仍然跳转到本DIV
                            e.preventDefault();
                            bind_demo(_element, $(this).attr("href"));
                        });
                        $("form").submit(function(e){  //绑定所有的form事件改为提交后仍跳转到本页
                            e.preventDefault();
                            $(this).ajaxSubmit({
                                target: _element
                            });
                        });
                    });
                };
                
                $("#send").click(function(){
                    bind_demo("#resText", "/user/userList");
                });
            });
        </script>
        <title>用户ajax</title>
    </head>
    <body>
        <input type="button" id="send" value="调用1"><a href="#">我点</a>
        <div id = "resText">
        </div>
    </body>
</html>
